package com.teamwechat.controller;

import com.teamwechat.common.utils.R;
import com.teamwechat.vo.TestSayHelloVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequestMapping("/test")
@Api("测试Web接口")//Swagger声明类加@Api注解, 并说明
public class TestController {

    @PostMapping("/sayHello")
    @ApiOperation("最简单的测试方法") //Swagger声明方法添加@ApiOperation注解,(方法说明)
    public R sayHello(@Valid @RequestBody TestSayHelloVo vo){
        return R.ok().put("msg", "你好啊"+vo.getName());
    }

    @PostMapping("/testsauhelloVo")
    @ApiOperation("/testsauhelloVod的测试方法，测试后端校验功能")
        public R testsauhelloVo(@Valid @RequestBody TestSayHelloVo vo){
            return R.ok("姓名 "+vo.getSname() + "密码 "+vo.getPassword());
        }
}